﻿using SmartParkingClient.Entity;
using SmartParkingClient.IBLL;
using SmartParkingClient.IDAL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity;

namespace SmartParkingClient.BLL
{
    public class MenuBLL : IMenuBLL
    {
        [Dependency]
        public IMenuDal menuDal { get; set; }

        public async Task<List<MenuEntity>> GetMenus(int id)
        {
            List<MenuEntity> menuEntities = new List<MenuEntity>();

            var menus = await menuDal.GetMenu(id);// Result
            var result = System.Text.Json.JsonSerializer.Deserialize<ResultEntity<List<MenuEntity>>>(menus);
            if (result.state == 200)
            {
                menuEntities = result.data;// 这个赋值是否可行？
            }
            else
                throw new Exception(result.exceptionMessage);

            return menuEntities;
        }
    }
}
